package com.owlsmart.bluecat.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.just.agentweb.AgentWeb;
import com.owlsmart.bluecat.R;

public class BrowserActivity extends BaseActivity {

    private String url;
    protected AgentWeb mAgentWeb;
    private FrameLayout frameLayout;

    @Override
    protected int initLayout() {
        return R.layout.activity_browser;
    }

    @Override
    protected void initView() {
        frameLayout = findViewById(R.id.bridgeWebView_browser);
    }

    @Override
    protected void initDate() {
        // 获取上一级传过来的bundle
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            url = bundle.getString("url");
        }
        initWebView();
    }

    private void initWebView() {

        // WebSettings settings = bridgeWebView.getSettings();
        // settings.setJavaScriptEnabled(true);
        // settings.setNeedInitialFocus(true);
        // settings.setSupportZoom(true);
        // settings.setLoadWithOverviewMode(true);
        // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS );
        // settings.setLoadsImagesAutomatically(true);
        //
        //
        // settings.setUseWideViewPort(true);
        // //
        //
        // //
        // settings.setTextZoom(300);
        // bridgeWebView.loadUrl(url);
        // // bridgeWebView.loadDataWithBaseURL(null, getHtmlData(url), "text/html", "UTF_8", null);

        mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent( frameLayout, new ViewGroup.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go(url);
        mAgentWeb.getAgentWebSettings().getWebSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小
        mAgentWeb.getAgentWebSettings().getWebSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小
        // mAgentWeb.getAgentWebSettings().getWebSettings().setTextZoom(300);

    }
}